<?php
global $conn;

function connectDB()
{
    global $conn;
    $servername="127.0.0.1";
    $username="root";
    $password="zd20030315";
    $dbname="xlsystem";
    $port=3306;

    $conn = new mysqli($servername, $username, $password, $dbname, $port);
    if ($conn->connect_error) {
        header('Content-Type: application/json');
        echo json_encode([
            'success' => false,
            'message' => '数据库连接失败',
            'data' => null,
            'errors' => $conn->connect_error
        ]);
        exit();
    }
}

// 调用函数建立数据库连接
connectDB();

